#include <vector>
#include <string>
#include <limits> // 用于 INT_MIN
#include "Hash.h"

using namespace std;

template <typename T1, typename T2>
class HashTable
{
private:
    int _size;
    Hash<T1> _hash;
    vector<T2 *> table;

public:
    HashTable(int size) : _size(size), _hash(size), table(_size)
    {
    }

    void addItem(const T1 &key, const T2 &value)
    {
        table[_hash(key)] = new T2(value);
    }

    void removeItem(const T1 &key)
    {
        table[_hash(key)] = nullptr;
    }

    T2 *findByKey(const T1 &key)
    {
        if (table[_hash(key)] == nullptr)
        {
            return nullptr;
        }
        else
        {
            return table[_hash(key)];
        }
    }
};
